package beans;

import java.util.Date;
import java.util.GregorianCalendar;



public class Timer {
		   private int time;
		   GregorianCalendar gc1;
		   GregorianCalendar gc2;
	      // the above two dates are one second apart
	   
	      public Timer() {
	    	  gc1 = new GregorianCalendar();
	   }
	   public synchronized String getCounter() {
		      Date d1 = gc1.getTime();
		      gc2 = new GregorianCalendar();
		      Date d2 = gc2.getTime();
		      long l1 = d1.getTime();
		      long l2 = d2.getTime();
		      long difference = l2 - l1;
		      int timeInSeconds = (int)(difference/1000);
		      int minutes, seconds;
		      minutes = timeInSeconds / 60;
		      timeInSeconds = timeInSeconds - (minutes * 60);
		      seconds = timeInSeconds;
	      return ""+minutes +":" + seconds;
	   }

	   public synchronized int setCounter(int c) {
	      time = c;
	      return time;
	   }
	}
	 